package com.mallcai.bigdata.ladon.service.report.impl.handler;

import com.mallcai.bigdata.ladon.dpl.entity.report.Report;
import com.mallcai.bigdata.ladon.service.report.impl.ReportQueryConstants;
import com.mallcai.bigdata.ladon.service.report.impl.ReportQueryContext;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

/**
 * @author feixy
 * @version 1.0
 * @date 2019-08-23 11:05
 */
@Component
@Order(510)
public class SetQueryMarkHandler extends AbstractReportQueryPreHandler {


    @Override
    public void preInternal(ReportQueryContext context) {
        Report report = context.getReport();
        context.putInnerParam(ReportQueryConstants.KEY_IS_FLOW_OFF, isFlowOff(report.getFlowSwitch()));
        context.putInnerParam(ReportQueryConstants.KEY_IS_STATIC_REPORT, isStaticReport(report.getStatical()));
        context.putInnerParam(ReportQueryConstants.KEY_IS_CACHE_RESULT, false);

    }

    private boolean isFlowOff(int flowSwitch){
        return flowSwitch == 1;
    }

    private boolean isStaticReport(int staticReport){
        return staticReport == 1;
    }

}
